<script>
	import {Login} from "api/login.js"
	export default {
		data(){
			return {
				code:undefined
			}
		},
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		created() {
			let self = this
			wx.login({
				success: (res) => {
					if(res.code) {
						let code = res.code;
						uni.setStorageSync({
							code
						})
					} else {
						
					}
				}
			})
			
			// uni.login({
			//   provider: 'weixin',
			//   success: function (loginRes) {
			//     console.log(loginRes.authResult);
			//     // 获取用户信息
			//     uni.getUserInfo({
			//       provider: 'weixin',
			//       success: function (infoRes) {
			// 		  console.error(JSON.stringify(infoRes))
			//         console.log('用户昵称为：' + infoRes.userInfo.nickName);
			//       }
			//     });
			//   }
			// });
		}
		,
		methods:{
			dologin(){
				Login({code:this.code}).then(res=>{
					let {code,msg} = res
					if(code == 500) {
						uni.showToast({
							title:msg,
							icon:"none"
						})
					} else {
						
					}
				}).catch(e=>{
					
					debugger
				})
			}
		}
	}
</script>

<style>
	uni-page-body {
		height: 100%;
		display: flex;
	}

	page {
		height: 100%;
		display: flex;
	}
</style>
